<?php
/**
 * 编辑课程
 */

include "../util/DBUtil.php";

$action = $_GET['flag'];//操作标志
$id = $_GET['id'];
$db = new DBUtil();
if ($action == 0) {//修改
    $sql = "select * from tb_course where id=? ";
    $params = array($id);
    $result = $db->query($sql, $params)[0];
} elseif ($action == 1) {//删除
    $sql = "delete from tb_score where id=? ";//删除成绩表中含有该课程
    $params = array($id);
    $sql = "delete from tb_course where id=? ";//删除课程
    $db->update($sql, $params);
    echo "<script>alert('删除成功');window.open('course.php','info')</script>";
}
?>

<form action="../action/course_formOK.php" method="post">
    <input type="hidden" name="id" value="<?php echo $result['id'] ?>">
    课程：<input type="text" name="course" value="<?php echo $action == 0 ? $result['course'] : '' ?>">
    <button type="submit">确定</button>
</form>

